import request from '@/utils/request.js'

export const login = data => {
	return request({
		method: 'POST',
		url: '/v1_0/authorizations',
		data
	})
}

export const sendSms = mobile => {
	return request({
		url: `/v1_0/sms/codes/${mobile}`,
	})
}

export const getUserInfo = () => {
	return request({
		url: '/v1_0/user',
	})
}

export const getUserChannels = () => {
	return request({
		url: '/v1_0/user/channels',
	})
}

export const addFollow = target => {
	return request({
		method: 'POST',
		url: '/v1_0/user/followings',
		data: {
			target
		}
	})
}

export const deleteFollow = target => {
	return request({
		method: 'DELETE',
		url: `/v1_0/user/followings/${target}`,
	})
}

export const getUserProfile = () => {
	return request({
		url: '/v1_0/user/profile'
	})
}

export const updateUserProfile = data => {
	return request({
		method: 'PATCH',
		url: '/v1_0/user/profile',
		data
	})
}

export const updateUserPhoto = data => {
	return request({
		method: 'PATCH',
		url: '/v1_0/user/photo',
		data
	})
}

export const exchangeTokenAPI = rq => {
	return request({
		method: 'PUT',
		url: '/v1_0/authorizations',
		headers: {
			Authorization: `Bearer ${rq}`
		}
	})
}
